<?php
class SupplierUsersController extends AppController {
    var $name = 'SupplierUsers';

    var $pageTitle = 'User Information';

    var $viewPath = 'suppliers/admins/users';

    var $uses = array('User', 'Supplier', 'UserSupplier', 'UserHistory');

    var $paginate = array('UserSupplier' => array('order' => 'User.id DESC', 'contain' => array('User')));

    function beforeFilter() {
        parent::beforeFilter();
        $this->set('parentNav', 'supplier_admins');
        $this->set('tabMenu', 'tabmenus/supplier/admins');
    }

    function display() {
        $this->data['UserSupplier']['supplier_id'] = $this->Auth->user('supplier_id');
        parent::display('UserSupplier');
        $this->_paging('UserSupplier', array('username' => 'LIKE', 'name' => 'LIKE', 'surname' => 'LIKE', 'email' => 'LIKE', 'tel' => 'LIKE'));
    }

    function view($id) {
        $this->data = $this->UserSupplier->findById($id);
        $this->data['User']['password'] = '';
        $this->data['User']['password_confirm'] = '';
        $this->UserSupplier->id = $id;
        $this->set('neighbors', $this->UserSupplier->find('neighbors', array(
                    'fields' => array('id'),
                    'conditions' => array('supplier_id' => $this->Auth->user('supplier_id'))
                )
            )
        );
    }

    function popup_search() {
        parent::popup_search();
    }
}
?>